﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Fluent="clr-namespace:Fluent" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

    <ControlTemplate x:Key="BackstageToggleButtonControlTemplate" TargetType="{x:Type Fluent:Backstage}">
        <Border x:Name="border2" MinWidth="60" Height="24" Background="{TemplateBinding Background}" Margin="0,0,1,0">
            <Grid>
                <Rectangle x:Name="rectangle" />
                <ContentPresenter x:Name="contentPresenter" ContentSource="Header" Margin="10,0,10,0"
                                  VerticalAlignment="Center" HorizontalAlignment="Center" />
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Fill" TargetName="rectangle" Value="#3FFFFFFF" />
            </MultiTrigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Opacity" TargetName="border2" Value="0.5" />
                <Setter Property="Effect" TargetName="contentPresenter">
                    <Setter.Value>
                        <Fluent:GrayscaleEffect />
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="IsOpen" Value="True">
                <Setter Property="Visibility" TargetName="rectangle" Value="Collapsed" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" SourceName="border2" />
                    <Condition Property="IsOpen" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Visibility" TargetName="rectangle" Value="Collapsed" />
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="RibbonBackstageStyle"
           TargetType="{x:Type Fluent:Backstage}">
        <Setter Property="Template" Value="{StaticResource BackstageToggleButtonControlTemplate}" />
        <Setter Property="Background"
                Value="{Binding RibbonThemeColor, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:MetroWindow}}}" />
        <Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}" />
        <Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Fluent:FrameworkHelper.UseLayoutRounding" Value="True" />
    </Style>

    <Style TargetType="{x:Type Fluent:Backstage}" BasedOn="{StaticResource RibbonBackstageStyle}" />
</ResourceDictionary>